<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:substituteby="template::docHead(#{system.name},'商户管理')">
</head>
<body>
<script type="text/javascript" th:substituteby="system/authorization/groups.js::js"></script>
<nav th:replace="template::nav"></nav>
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-12 col-md-12 main">
            <nav class="navbar navbar-default">
                <div class="container-fluid">
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                                data-target="#bs-example-navbar-collapse-2" aria-expanded="false">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <a class="navbar-brand" href="#">商户管理：</a>
                    </div>
                    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
                        <button type="button" class="btn btn-primary navbar-btn" data-toggle="modal"
                                data-target="#myModal">
                            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
                            创建商户
                        </button>
                        <form class="navbar-form navbar-right" role="search" th:action="@{./users}">
                            <div class="form-group">
                                <input type="text" class="form-control" placeholder="查询" id="userName" name="userName"/>
                                <input type="hidden" name="page.pageSize" id="pageSize"
                                       th:value="${result.page.pageSize}"/>
                                <input type="hidden" name="page.currentPage" id="currentPage"
                                       th:value="${result.page.currentPage}"/>
                            </div>
                            <button type="submit" class="btn btn-default">查询</button>
                        </form>
                    </div>
                </div>
            </nav>
            <div class="modal fade" id="myModal-del" tabindex="-1" role="dialog" aria-labelledby="myModalLabel-del"
                 aria-hidden="true">
                <div class="modal-dialog" style="width: 400px;">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close"
                                    data-dismiss="modal" aria-hidden="true">
                                &times;
                            </button>
                            <h4 class="modal-title" id="myModalLabel-del">
                                确定删除商户？
                            </h4>
                        </div>
                        <div class="modal-body">
                            <p>
                                确定要删除商户<span id="delUserName"></span>吗？
                            </p>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default"
                                    data-dismiss="modal">关闭
                            </button>
                            <button type="button" class="btn btn-primary" id="doDel">
                                确定
                            </button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal -->
            </div>
            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                 aria-hidden="true">
                <div class="modal-dialog" style="width: 400px;">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close"
                                    data-dismiss="modal" aria-hidden="true">
                                &times;
                            </button>
                            <h4 class="modal-title" id="myModalLabel">
                                创建商户户
                            </h4>
                        </div>
                        <form th:action="@{./users}" method="post">
                            <div class="modal-body">
                                <div class="input-group" style="margin-bottom: .5em;">
                                    <span class="input-group-addon" id="basic-username">商户名称</span>
                                    <input type="text" id="addUserName" name="addUserName" class="form-control"
                                           placeholder="商户名称"
                                           aria-describedby="basic-username"/>
                                </div>
                                <div class="input-group" style="margin-bottom: .5em;">
                                    <span class="input-group-addon" id="description">描述</span>
                                    <textarea class="form-control" rows="3" placeholder="描述"
                                              aria-describedby="description"></textarea>
                                </div>
                                <label class="checkbox-inline">
                                    <input type="radio" id="inlineCheckbox1" name="isvalidable" value="option1" checked="checked" />&nbsp;有效
                                </label>
                                <label class="checkbox-inline">
                                    <input type="radio" id="inlineCheckbox2" name="isvalidable" value="option2" />&nbsp;无效
                                </label>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default"
                                        data-dismiss="modal">关闭
                                </button>
                                <button type="button" class="btn btn-primary">
                                    确定
                                </button>
                            </div>
                        </form>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal -->
            </div>
            <div class="modal fade" id="myModal-update" tabindex="-1" role="dialog"
                 aria-labelledby="myModalLabel-update"
                 aria-hidden="true">
                <div class="modal-dialog" style="width: 400px;">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close"
                                    data-dismiss="modal" aria-hidden="true">
                                &times;
                            </button>
                            <h4 class="modal-title" id="myModalLabel-update">
                                修改用户
                            </h4>
                        </div>
                        <form th:action="@{./users/update}" method="post">
                            <input type="hidden" name="userId" id="userId"/>
                            <div class="modal-body">
                                <div class="input-group" style="margin-bottom: .5em;">
                                    <span class="input-group-addon" id="basic-username-update">&nbsp;用&nbsp;&nbsp;户&nbsp;&nbsp;名&nbsp;</span>
                                    <input type="text" id="addUserName-update" name="addUserName" class="form-control"
                                           placeholder="用户名"
                                           aria-describedby="basic-username"/>
                                </div>
                                <div class="input-group" style="margin-bottom: .5em;">
                                    <span class="input-group-addon" id="basic-pwd-update">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码&nbsp;</span>
                                    <input type="password" id="pwd-update" name="password" class="form-control"
                                           placeholder="密码"
                                           aria-describedby="basic-pwd"/>
                                </div>
                                <div class="input-group" style="margin-bottom: .5em;">
                                    <span class="input-group-addon" id="basic-pwd2-update">确&nbsp;认&nbsp;密&nbsp;码</span>
                                    <input type="password" id="pwd2-update" name="password2" class="form-control"
                                           placeholder="再输入一次密码"
                                           aria-describedby="basic-pwd2"/>
                                </div>
                                <label>拥有角色</label>

                                <div id="roles">
                                    <div th:each="role:${roles}" class="checkbox-inline">
                                        <label>
                                            <input type="checkbox" th:value="${role.rolename}"
                                                   name="roles"/><span th:text="${role.rolename}"/>
                                        </label>
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default"
                                        data-dismiss="modal">关闭
                                </button>
                                <button type="submit" class="btn btn-primary">
                                    确定
                                </button>
                            </div>
                        </form>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal -->
            </div>
            <div class="table-responsive">
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>商户名称</th>
                        <th>描述</th>
                        <th>创建时间</th>
                        <th>是否有效</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="result:${result.result}">
                        <td th:text="${result.id}"></td>
                        <td th:text="${result.name}"></td>
                        <td th:text="${result.descript}"></td>
                        <td th:text="${result.createTime==null?'-':#dates.format(result.createTime, 'yyyy-MM-dd HH:mm:ss')}"></td>
                        <td th:switch="${result.state}">
                            <span th:case="0">有效</span>
                            <span th:case="1">无效</span>
                        </td>
                        <td></td>
                    </tr>
                    </tbody>
                </table>
                <nav style="float: right;">
                    <ul th:if="${result.page.totalPage>0}" class="pagination">
                        <li>
                            <a th:href="@{./users(pager.currentPage=${1},page.pageSize=${result.page.pageSize})}"
                               aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                        <li th:each="i,status:${#numbers.sequence( 0, result.page.totalPage-1)}">
                            <a th:href="@{./users(pager.currentPage=${status.index+1},page.pageSize=${result.page.pageSize})}"
                               th:text="${status.index+1}"></a>
                        </li>

                        <li>
                            <a th:href="@{./users(pager.currentPage=${result.page.totalPage},page.pageSize=${result.page.pageSize})}"
                               aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </ul>
                </nav>
            </div>
        </div>
    </div>
</div>
</body>
</html>
